options ls = 100 ps = 80 probsig=2;
libname gmath 'g:\data\math\';

data temp1; set gmath.iat;
   expstro = Efmlmale - Mfmlmale;

proc standard mean = 0 std = 1 out = temp1;
  var temp EXPpref mathtemp engltemp Mposavg Eposavg expstro mstro;
run;
/*proc corr; var expstro mstro;run;*/

data temp1;
   set temp1;
   expcomp = mean (temp, EXPpref);
   expmath = mean (mathtemp, Mposavg);
   expverb = mean (engltemp, Eposavg);
   impmath = mean (LMpmath, MApmath, SApmath, PEpmath);
   impverb = mean (LMnmath, MAnmath, SAnmath, PEnmath);
   impcomp = mean (LM, PE, MA, SA);
   expself = mean (expsl, martcomp);
   expself = -(expself);
   impatt = mean (LM, PE, NL);
   if sub < 400 then exp = 1; else if sub > 1000 then exp = 3; else exp = 2;
   if gen = 0 then gen = -1;
   /*to test interaction*/ if gen = -1 then gid = -1*gid;
   Gmstro = gen*mstro; Gexpstro = gen*expstro; GIDstro = gid*mstro; genGID = gen*gid;
   gGIDstro = gen*mstro*gid;
   gimpcomp = gen*impcomp; gidimpcomp = gid*impcomp; 
   gim = gen*im; gidim = gid*im;
   gsatperf = gen*satperf; gidsat = gid*satperf;
   gsatmath = gen*satmath; gidsatmath = gid*satmath;
   if maj > 1 then maj = 2;
   if maj = 1 and gen = -1 then majgen = -3; if maj=1 and gen=1 then majgen=-1;
   if maj = 2 and gen = -1 then majgen = 1; if maj=2 and gen=1 then majgen=3;
   if sex = 'f' and maj = 1 then mg = -1; else mg = 1;
   if race = 'asian' then rc = 1; if race = 'white' then rc = -1;
   if order = 'firstord' then ord = -1; if order = 'secndord' then ord = 1;
   if maj = 1 then maj = -1; else if maj = 2 then maj = 1;
   genmaj = gen*maj; 

proc corr; var SATperf expself im;run;
proc reg; model SATperf = expself im/stb;run;

proc sort; by gen;
proc corr; by gen; var SATperf mstro expstro;run;

proc reg; model IM = gen mstro gmstro /stb;run;
proc reg; model IM = gen gid gengid /stb;run;
proc reg; model mstro = gen gid gengid /stb;run;

proc means; class gen maj; var impcomp expcomp;run;
proc means; class maj; var impcomp;run;
proc means; class gen; var impcomp;run;
proc means; class maj; var expcomp;run;
proc means; class gen; var expcomp;run;

proc corr nomiss; var MA expcomp;run;

/*Workshop regression examples
    SATperf = SAT math score - SAT verbal score
    expcomp = explicit math attitude - explicit arts attitude
    impcomp = implicit math attitude - implicit arts attitude
    gen = participant sex (-1 = male; 1 = female)
    expstro = explicit math+male/female+arts stereotype
    mstro = implicit math+male/female+arts stereotype
	gid = implicit gender identity
*/
proc print; var SATperf expcomp impcomp gen expstro mstro gid;run;

/*comparing zero-order correlations with regression coefficients*/
proc corr nomiss; var satperf impcomp expcomp;run;
proc reg; model satperf = expcomp /stb pcorr2 scorr2;
          model satperf = impcomp /stb pcorr2 scorr2;
		  model satperf = expcomp impcomp /stb pcorr2 scorr2;run;

/*hierarchical regression predicting explicit math attitudes
    1st step -- person variables (gender)
	2nd step -- explicit gender-math stereotypes
	3rd step -- implicit math attitudes, math stereotypes, gender identity*/
proc reg; model expcomp = gen /stb;
          model expcomp = gen expstro /stb;
		  model expcomp = gen expstro impcomp mstro gid /stb;run;

/*Interactions in regression*/
proc reg; model expcomp = expstro mstro gen /stb;
          model expcomp = expstro mstro gen Gexpstro Gmstro /stb;run;

/*effects coding -->  -1 = male; 1 = female*/
proc reg; model impcomp = gen /stb;run;
/*dummy coding -->  0 = male; 1 = female*/
data temp1; set temp1; if gen = -1 then gen = 0;
proc reg; model impcomp = gen /stb;run;

/*stepwise regression -- forward*/
proc reg; model expcomp = gen expstro impcomp mstro gid /selection=forward sle=.100 stb;run;


/*ANOVA in regression --> math-related majors = 1; non-math majors = -1*/
proc glm;  model impcomp = gen|maj; run;
proc reg;  model impcomp = gen maj /stb;
           model impcomp = gen maj genmaj /stb;run;



/*proc corr; var impcomp im satperf satmath satverb;run;
proc corr; var expcomp expself satperf;run;
proc corr; var impcomp im gid; with expcomp expself expstro;run;*/

/*proc reg; model impcomp im expcomp expself satperf = Gexpstro expstro gen /stb;
          where exp=3;run;
proc reg; model impcomp im expcomp expself satperf = mstro expstro gen Gmstro Gexpstro /stb;
          where exp=3;run;
proc sort; by gen;
proc corr; var impcomp im expcomp expself satperf; with mstro expstro; by gen;run;

proc glm; model mstro = gen; run;
proc corr; by gen;var mstro SATperf SATmath;run;
*/
/*proc reg; model satperf = impcomp expcomp /stb;run;
proc reg; model satmath = impcomp expcomp /stb;run;
proc reg; model satperf = im expself /stb;run;

proc reg; model expcomp = gen /stb; where maj = -1;run;
proc means; class gen; var expcomp; where maj = -1;run;
proc glm; model impcomp expcomp = ; repeated att 2;where gen = 1 and maj = 1;run;
proc glm; model impcomp expcomp = ; repeated att 2;where gen = -1 and maj = 1;run;
proc glm; model impcomp expcomp = ; repeated att 2;where gen = -1 and maj = -1;run;
proc glm; model impcomp expcomp = ; repeated att 2;where gen = 1 and maj = -1;run;*/

/*proc contents;run;
proc glm; class gen maj; model impcomp = maj|gen;run;
proc glm; class gen maj; model expcomp = maj|gen;run;
proc reg; model impcomp = gen maj genmaj/stb;run;

proc standard mean=0 std=1 out=temp1; var impcomp expcomp;run;
proc means n mean t prt; class gen maj; var impcomp expcomp;run;
proc glm; class gen maj; model impcomp expcomp = gen|maj; repeated att 2; means gen|maj /tukey;run;
proc glm; model impcomp expcomp = ;repeated att 2; where gen = 1 and maj = -1;run;*/

/*
proc means; class gen maj; var impcomp;run;
proc glm; class gen; model impcomp = gen; where maj = 1;run;
proc glm; class gen; model impcomp = gen; where maj = 2;run;
proc glm; class gen; model expcomp = gen; where maj = 1;run;
proc glm; class gen; model expcomp = gen; where maj = 2;run;*/

/*proc reg; model impcomp = gen mstro /stb;
          model impcomp = gen mstro gmstro /stb;
          model impcomp = gid mstro /stb;
          model impcomp = gid mstro gidstro /stb;run;
proc reg; model im = gen mstro /stb;
          model im = gen mstro gmstro /stb;
          model im = gid mstro /stb;
          model im = gid mstro gidstro /stb;run;
proc reg; model SATperf = gen mstro /stb;
          model SATperf = gen mstro gmstro /stb;
          model SATperf = gid mstro /stb;
          model SATperf = gid mstro gidstro /stb;run;
proc reg; model SATmath = gen mstro /stb;
          model SATmath = gen mstro gmstro /stb;
          model SATmath = gid mstro /stb;
          model SATmath = gid mstro gidstro /stb;run;*/

/*proc reg; where gen = -1;
          model impcomp = gid mstro /stb;
          model impcomp = gid mstro gidstro /stb;run;
proc reg;  where gen = -1;
          model im = gid mstro /stb;
          model im = gid mstro gidstro /stb;run;
proc reg;  where gen = -1;
          model SATperf = gid mstro /stb;
          model SATperf = gid mstro gidstro /stb;run;
proc reg;  where gen = -1;
          model SATmath = gid mstro /stb;
          model SATmath = gid mstro gidstro /stb;run;*/

/*proc reg; where gen = 1;
          model impcomp = gid mstro /stb;
          model impcomp = gid mstro gidstro /stb;run;
proc reg;  where gen = 1;
          model im = gid mstro /stb;
          model im = gid mstro gidstro /stb;run;
proc reg;  where gen = 1;
          model SATperf = gid mstro /stb;
          model SATperf = gid mstro gidstro /stb;run;
proc reg;  where gen = 1;
          model SATmath = gid mstro /stb;
          model SATmath = gid mstro gidstro /stb;run;*/

/*
proc reg; model mstro = gen impcomp /stb;
          model mstro = gen impcomp gimpcomp /stb;
          model mstro = gid impcomp /stb;
          model mstro = gid impcomp gidimpcomp /stb;run;
proc reg; model mstro = gen im /stb;
          model mstro = gen im gim /stb;
          model mstro = gid im /stb;
          model mstro = gid im gidim /stb;run;
proc reg; model mstro = gen satperf /stb;
          model mstro = gen satperf gsatperf /stb;
          model mstro = gid satperf /stb;
          model mstro = gid satperf gidsat /stb;run;
proc reg; model mstro = gen satmath /stb;
          model mstro = gen satmath gsatmath /stb;
          model mstro = gid satmath /stb;
          model mstro = gid satmath gidsatmath /stb;run;
proc reg; model mstro = gen impcomp im /stb;
          model mstro = gen impcomp im gimpcomp gim /stb;
          model mstro = gid impcomp im /stb;
          model mstro = gid impcomp im gidimpcomp gidim /stb;run;
proc reg; model mstro = gen impcomp satperf /stb;
          model mstro = gen impcomp satperf gimpcomp gsatperf /stb;
          model mstro = gid impcomp satperf /stb;
          model mstro = gid impcomp satperf gidimpcomp gidsat /stb;run;
proc reg; model mstro = gen impcomp im satperf /stb;
          model mstro = gen impcomp im satperf gimpcomp gim gsatperf /stb;
          model mstro = gid impcomp im satperf /stb;
          model mstro = gid impcomp im satperf gidimpcomp gidim gidsat /stb;run;

proc reg; model impcomp = gid /stb; model impcomp = mstro /stb; model mstro = gid /stb;
		  model impcomp = gid mstro /stb;where gen = 1;run;
proc reg; model gid = mstro impcomp im/stb; model impcomp = gid mstro im /stb;
          model im = gid mstro impcomp /stb;
		  model mstro = gid impcomp im/stb;where gen = 1;run;
proc corr; var gid im impcomp mstro;where gen = 1;run;
proc corr; var gid im impcomp mstro;where gen = -1;run;*/

/*proc standard mean=0 std=1; var impcomp expcomp;run;*/
/*proc contents;run;*/
/*experiment 1  
proc glm; class sex; model NL = sex;run;
proc glm; class sex; model LM = sex;where sub < 400;run;
proc glm; class sex; model PE = sex;run;
proc glm; class sex; model impatt = sex;where sub < 400;run;
proc glm; model NL LM PE impatt = ;where sex = 'f' and sub < 400;run;
proc glm; model NL LM PE impatt = ;where sex = 'm' and sub < 400;run;
proc corr; var NL LM PE;run;*/

/*experiment 2
proc glm; model LM SA MA IM impcomp = ;where exp = 2;run;
proc glm; model LM SA MA IM impcomp = ;where sex = 'f' and exp = 2;run;
proc glm; model LM SA MA IM impcomp = ;where sex = 'm' and exp = 2;run;
proc glm; class sex; model impcomp = sex;where exp = 2;run;
proc glm; class sex; model MA = sex; where exp = 2;run;
proc glm; class sex; model LM = sex; where exp = 2;run;
proc glm; class sex; model SA = sex; where exp = 2;run;
proc glm; class sex; model IM = sex; where exp = 2;run;*/

/*simple effects with latency data
proc means n mean stderr; class sex; var LM NL PE; where exp = 1;run;
proc means n mean stderr; class sex; var LM SA MA IM; where exp = 2;run;
proc means n mean stderr; class sex; var MA IM Mstro GID; where exp = 3;run;*/

/*proc means;
  class sex;
  var LMpmath LMnmath MApmath MAnmath SApmath SAnmath NLpmath NLnmath PEpmath PEnmath Mathself Artsself
      Mathmasc Mathfem GIDmale GIDfem;run;

proc corr; var LM PE NL MA SA IM Mstro GID;run;
proc sort; by sex; proc corr; by sex; var MA IM Mstro GID SATperf;run;

proc sort; by sex; proc corr; by sex;var expcomp expself expstro mstro; where exp=3;run;
proc corr; by sex;var expcomp expself expstro MA IM mstro GID; where exp=3;run;*/

/*proc reg; model MA IM expcomp expself = mstro expstro /stb;
          model MA IM expcomp expself = mstro expstro gen Gmstro Gexpstro/stb;
          where exp=3;run;
proc corr; var expcomp expself MA IM GID SATperf mstro; where exp=3;run;

proc sort; by sex majorcat; proc corr; by sex majorcat; var expcomp impcomp;run;*/

/*proc glm; class majgen; model impcomp expcomp = majgen;repeated att 2;run;
proc glm; class sex; model impcomp = sex;where maj = 1;run;
proc glm; class sex; model expcomp = sex;where maj = 1;run;
proc glm; model impcomp expcomp = ;repeated att 2;where sex='f' and maj=1;run;
proc means n mean stderr; class sex maj;var expcomp impcomp;run;
proc glm; class mg; model impcomp expcomp = mg;repeated att 2;run;*/


/*proc means; class expstro; var impcomp; run;
proc means; class sex expstro; var impcomp; run;
proc means; class sex Efmlmale; var impcomp; run;
proc means; class sex Mfmlmale; var impcomp; run;

proc corr; var expcomp expself expstro; with impcomp im gid; where exp=3;run;
proc means; class maj; var impcomp;run;
proc means; class orderme; var impcomp;run;

proc reg; model impcomp = maj gen rc /stb; run;

proc contents;run;

proc corr; var expcomp impcomp SATperf usemath;run;
proc sort; by gen;proc corr; by gen; var expcomp impcomp SATperf usemath;run;
proc reg; model SATperf = expcomp /stb; model SATperf = impcomp /stb;
          model SATperf = expcomp impcomp /stb; model impcomp = expcomp /stb;run;*/

/*job talk analyses*/
/*proc means; class sex; var im mstro impcomp gid satperf; where exp=3;run;
proc means; var im mstro impcomp gid; where exp=3;run;
proc reg; model im = mstro /stb; where sex='f' and exp=3;run;
proc reg; model im = mstro /stb; where sex='m' and exp=3;run;
proc reg; model impcomp = mstro /stb; where sex='f' and exp=3;run;
proc reg; model impcomp = mstro /stb; where sex='m' and exp=3;run;
proc reg; model im = gid /stb; where sex='f' and exp=3;run;
proc reg; model im = gid /stb; where sex='m' and exp=3;run;
proc reg; model impcomp = gid /stb; where sex='f' and exp=3;run;
proc reg; model impcomp = gid /stb; where sex='m' and exp=3;run;
proc reg; model satperf = mstro /stb; where sex='f' and exp=3;run;
proc reg; model satperf = mstro /stb; where sex='m' and exp=3;run;
proc reg; model satperf = gid /stb; where sex='f' and exp=3;run;
proc reg; model satperf = gid /stb; where sex='m' and exp=3;run;
proc reg; model mstro = gid /stb; where sex='f' and exp=3;run;
proc reg; model mstro = gid /stb; where sex='m' and exp=3;run;*/

/*proc reg; model impcomp = gid mstro /stb; where sex='f' and exp=3;run;
proc reg; model im = gid mstro /stb; where sex='f' and exp=3;run;
proc reg; model satperf = gid mstro /stb; where sex='f' and exp=3;run;

proc reg; model impcomp = gid mstro /stb; where sex='m' and exp=3;run;
proc reg; model im = gid mstro /stb; where sex='m' and exp=3;run;
proc reg; model satperf = gid mstro /stb; where sex='m' and exp=3;run;

proc sort; by sex;
proc corr; var impcomp im satperf gid mstro; by sex; where exp=3;run;

proc corr; var mstro expstro impcomp im expcomp expself satperf;by sex; where exp=3;run;*/